<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>js日期设定</title>
	</head>

	<body>
		<div class="bj" id="bj">
			<p></p>
			<span></span>
			<span></span>
			<span></span>
			<span></span>
			<span></span>
		</div>
		<div class="gj" id="gj">
			<p></p>
			<span></span>
			<span></span>
			<span></span>
			<span></span>
			<span></span>
		</div>
		<script>
			var bj = document.getElementById('bj');
			var p = document.getElementsByTagName('p')[0];
			var spany = bj.getElementsByTagName('span')[0];
			var spanr = bj.getElementsByTagName('span')[1];
			var spans = bj.getElementsByTagName('span')[2];
			var spanf = bj.getElementsByTagName('span')[3];
			var spanm = bj.getElementsByTagName('span')[4];
			var s = false;
			var date = new Date();

			function bjt() {
				if (!s) {
					if (new Date().getHours() == 20 && new Date().getMinutes() == 02) {
						s = confirm('该吃饭了')
					}
				}
				p.innerHTML = '北京时间'
				spany.innerHTML = new Date().getMonth() + 1 + "月:";
				spanr.innerHTML = new Date().getDate() + "日:";
				spans.innerHTML = new Date().getHours() + "时:";
				spanf.innerHTML = new Date().getMinutes() + "分:";
				spanm.innerHTML = new Date().getSeconds() + "秒";
			}
			bjt();
			setInterval(bjt, 1000)
				//			var gj = document.getElementById('gj');
				//			var pp = document.getElementsByTagName('p')[1];
				//			var spanya = gj.getElementsByTagName('span')[0];
				//			var spanra = gj.getElementsByTagName('span')[1];
				//			var spansa = gj.getElementsByTagName('span')[2];
				//			var spanfa = gj.getElementsByTagName('span')[3];
				//			var spanma = gj.getElementsByTagName('span')[4];
				//			 			var dateaa = new Date();
				//
				//			function gjt() {
				//				pp.innerHTML = '世界时间'
				//				spanya.innerHTML = new Date().getUTCMonth() + 1 + "月:";
				//				spanra.innerHTML = new Date().getUTCDate() + "日:";
				//				spansa.innerHTML = new Date().getUTCHours() + "时:";
				//				spanfa.innerHTML = new Date().getUTCMinutes() + "分:";
				//				spanma.innerHTML = new Date().getUTCSeconds() + "秒";
				//			}
				//			gjt();
				//
				//			function t() {
				//				bjt();
				//				gjt();
				//			}
				//			setInterval(t, 17)
				//			
				//			
				//			
				//			setInterval(function() {
				//				var date1 = new Date();
				//				var date2 = new Date();
				//				var hour = date2.setHours(12);
				//				var minute = date2.setMinutes(10);
				//				var second = date2.setSeconds(55);
				//				time = (date2.getTime()) - (date1.getTime());
				//				var date3 = new Date(time);
				//				second = Math.floor(time / 1000 % 60);
				//				minute = Math.floor(time / 1000 / 60);
				//				hour = Math.floor(time / 1000 / 60 / 60);
				//				p.innerHTML = hour + '时' + minute + '分' + second + '秒'
				//			}, 1000)
		</script>
	</body>

</html>